function areaOfMaxDiagonal(dimensions) {
  let maxDiagonalSquared = 0;
  let maxArea = 0;

  for (const [length, width] of dimensions) {
    // 计算对角线的平方（避免开方运算，提高效率）
    const diagonalSquared = length * length + width * width;
    // 计算面积
    const area = length * width;

    // 如果当前对角线更长，更新最大值
    if (diagonalSquared > maxDiagonalSquared) {
      maxDiagonalSquared = diagonalSquared;
      maxArea = area;
    }
    // 如果对角线长度相同，取面积更大的
    else if (diagonalSquared === maxDiagonalSquared) {
      maxArea = Math.max(maxArea, area);
    }
  }

  return maxArea;
}

// 示例测试
console.log(
  areaOfMaxDiagonal([
    [9, 3],
    [8, 6],
  ])
); // 输出: 48
console.log(
  areaOfMaxDiagonal([
    [3, 4],
    [4, 3],
  ])
); // 输出: 12
